﻿function fireParentForm(LocationType, WebpartIdPermission, PermissionCode) {
}

function ClientSaveOnClick() {
    var ltype = $("#_locationLevelTypeSelect").val();
    if (ltype == "0") {
        alert("Chưa chọn cấp địa phương!");
        document.getElementById("_locationLevelTypeSelect").select();
        document.getElementById("divProcessing").innerHTML = "";
        return;
    }
    var locationid = $("#_locationsel").val();
    if (locationid == null) {
        alert("Địa phương không hợp lệ, vui lòng chọn lại!");
        document.getElementById("_locationsel").select();
        document.getElementById("divProcessing").innerHTML = "";
        return;
    }
    //locationid = document.getElementById("_locationsel").options[document.getElementById("_locationsel").selectedIndex].value;
    tungay = document.getElementById("drpDaypldatefrom").options[document.getElementById("drpDaypldatefrom").selectedIndex].value + '/' + document.getElementById("drpMonthpldatefrom").options[document.getElementById("drpMonthpldatefrom").selectedIndex].value + '/' + document.getElementById("drpYearpldatefrom").options[document.getElementById("drpYearpldatefrom").selectedIndex].value;
    if (tungay == "//") {
        alert("Bạn chưa nhập ngày tháng!");
        document.getElementById("drpDaypldatefrom").focus();
    }

    sovu = document.getElementById("plsovu").value;
    sodtg = document.getElementById("plsodoituong").value;
    vnd = document.getElementById("plvnd").value;
    ngoaite = document.getElementById("plngoaite").value;
    daquy = document.getElementById("pldaquy").value;
    tskhac = document.getElementById("pltskhac").value;
    hungkhi = document.getElementById("plhungkhi").value;
    value = Portal.SODC.IDIS.AddNewPrecintIllegal.ServerSideAddNewPrecintIllegal(locationid,tungay, sovu, sodtg, vnd, ngoaite, daquy, tskhac, hungkhi).value;
    if (value.indexOf("ERROR") != -1) {
        alert(value.replace("ERROR:", ""));
        return;
    }
    alert(value);
    ClientAddNewPrecintIllegalResetAllField();
}

function ClientUpdateSaveOnClick(recordid) {
    var ltype = $("#_locationLevelTypeSelect").val();
    var locationid = $("#_locationsel").val();
    if (typeof (locationid) == 'undefined' || locationid == null) {
        var LocationId_Curent = $("#locationcurrentid").val();
        locationid = LocationId_Curent;
    }
    //locationid = document.getElementById("_locationsel").options[document.getElementById("_locationsel").selectedIndex].value;
    daterecord = document.getElementById("drpDaypudatefrom").options[document.getElementById("drpDaypudatefrom").selectedIndex].value + '/' + document.getElementById("drpMonthpudatefrom").options[document.getElementById("drpMonthpudatefrom").selectedIndex].value + '/' + document.getElementById("drpYearpudatefrom").options[document.getElementById("drpYearpudatefrom").selectedIndex].value;
    if (daterecord == "//") {
        alert("Bạn chưa nhập ngày tháng!");
        document.getElementById("drpDaypudatefrom").focus();
    }

    sovu = document.getElementById("pusovu").value;
    sodtg = document.getElementById("pusodoituong").value;
    vnd = document.getElementById("puvnd").value;
    ngoaite = document.getElementById("pungoaite").value;
    daquy = document.getElementById("pudaquy").value;
    tskhac = document.getElementById("putskhac").value;
    hungkhi = document.getElementById("puhungkhi").value;
    document.getElementById("divProcessing").innerHTML = "Hệ thống đang xử lý";
    value = Portal.SODC.IDIS.UpdatePILegal.ServerSideUpdatePrecintIllegal(recordid, locationid, daterecord, sovu, sodtg, vnd, ngoaite, daquy, tskhac, hungkhi).value;
    if (value.indexOf("ERROR") != -1) {
        document.getElementById("divProcessing").innerHTML = "";
        alert(value.replace("ERROR:", ""));
        return;
    }
    document.getElementById("divProcessing").innerHTML = "";
    alert(value);
    window.close();
}

function ClientAddNewPrecintIllegalResetAllField() {
    document.getElementById("drpDaypldatefrom").selectedIndex = 0;
    document.getElementById("drpMonthpldatefrom").selectedIndex = 0;
    document.getElementById("drpYearpldatefrom").selectedIndex = 0;
    //document.getElementById("pldateto").value="";
    document.getElementById("plsovu").value="";
    document.getElementById("plsodoituong").value="";
    document.getElementById("plvnd").value="";
    document.getElementById("plngoaite").value="";
    document.getElementById("pldaquy").value="";
    document.getElementById("pltskhac").value="";
    document.getElementById("plhungkhi").value="";
    document.getElementById("plvukhi").value = "";
    document.getElementById("drpDaypldatefrom").focus();
}

function FilterFunc() {
    document.getElementById("divProcessing").innerHTML = "Hệ thống đang xử lý";
    setTimeout("RealFilterFunc('', 0, 20, 10, 0, 'RealFilterFunc')", 10);
}

function RealFilterFunc(belongsite, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript) {
    var ltype = $("#_locationLevelTypeSelect").val();
    if (ltype == "0") {
        alert("Chưa chọn cấp địa phương!");
        document.getElementById("divProcessing").innerHTML = "";
        return;
    }
    var LocationId = $("#_locationsel").val();
    datefrom = document.getElementById("drpDayplistdatefrom").options[document.getElementById("drpDayplistdatefrom").selectedIndex].value + '/' + document.getElementById("drpMonthplistdatefrom").options[document.getElementById("drpMonthplistdatefrom").selectedIndex].value + '/' + document.getElementById("drpYearplistdatefrom").options[document.getElementById("drpYearplistdatefrom").selectedIndex].value;
    dateto = document.getElementById("drpDayplistdateto").options[document.getElementById("drpDayplistdateto").selectedIndex].value + '/' + document.getElementById("drpMonthplistdateto").options[document.getElementById("drpMonthplistdateto").selectedIndex].value + '/' + document.getElementById("drpYearplistdateto").options[document.getElementById("drpYearplistdateto").selectedIndex].value;
    retValue = Portal.SODC.IDIS.ListPrecintIllegal.GetHtmlResult(ltype, LocationId, datefrom, dateto, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript).value;
    if (retValue.indexOf("ERROR") != -1) {
        document.getElementById("divProcessing").innerHTML = "";
        alert(retValue.replace("ERROR:", ""));
        return;
    }
    document.getElementById("divProcessing").innerHTML = "";
    document.getElementById("resultcontent").innerHTML = retValue;
}

function ClientDeletePILegal(recordid, belongsite, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript) {
    Msg = Portal.SODC.IDIS.ListPrecintIllegal.GetConfirmDeleteMsg().value;
    if (confirm(Msg) == false) return;
    document.getElementById("divProcessing").innerHTML = "Hệ thống đang xử lý";
    RetValue = Portal.SODC.IDIS.ListPrecintIllegal.ServerSideDeletePILegal(recordid).value;
    if (RetValue.indexOf("ERROR") != -1) {
        document.getElementById("divProcessing").innerHTML = "";
        alert(RetValue.replace("ERROR:", ""));
        return;
    }
    document.getElementById("divProcessing").innerHTML = "";
    alert(RetValue);
    RealFilterFunc(belongsite, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript);
}

function ShowClientAddnewUrlForm() {
    document.getElementById("divProcessing").innerHTML = "Hệ thống đang xử lý";
    Url = Portal.SODC.IDIS.ListPrecintIllegal.GetShowAddNewForm().value;
    if (Url.indexOf("ERROR") != -1) {
        document.getElementById("divProcessing").innerHTML = "";
        alert(Url.replace("ERROR:", ""));
        return;
    }
    document.getElementById("divProcessing").innerHTML = "";
    window.open(Url, "_blank");    
}

function ShowClientViewdetailsForm(recordid, belongsite, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript) {
    document.getElementById("divProcessing").innerHTML = "Hệ thống đang xử lý";
    Url = Portal.SODC.IDIS.ListPrecintIllegal.GetShowDetailsForm(recordid).value;
    if (Url.indexOf("ERROR") != -1) {
        document.getElementById("divProcessing").innerHTML = "";
        alert(Url.replace("ERROR:", ""));
        return;
    }
    window.open(Url, "_blank");
    document.getElementById("divProcessing").innerHTML = "";
    RealFilterFunc(belongsite, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript);
}

function ShowClientUpdateUrlForm(recordid, belongsite, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript) {
    document.getElementById("divProcessing").innerHTML = "Hệ thống đang xử lý";
    Url = Portal.SODC.IDIS.ListPrecintIllegal.GetShowUpdateForm(recordid).value;
    if (Url.indexOf("ERROR") != -1) {
        document.getElementById("divProcessing").innerHTML = "";
        alert(Url.replace("ERROR:", ""));
        return;
    }
    window.open(Url, "_blank");
    document.getElementById("divProcessing").innerHTML = "";
    RealFilterFunc(belongsite, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript);
}

function ShowClientUpdateUrlFromviewform(RecordId) {
    document.getElementById("divProcessing").innerHTML = "Hệ thống đang xử lý";
    Url = Portal.SODC.IDIS.DetailsPrecintIllegal.GetShowUpdateForm(RecordId).value;
    if (Url.indexOf("ERROR") != -1) {
        document.getElementById("divProcessing").innerHTML = "";
        alert(Url.replace("ERROR:", ""));
        return;
    }
    document.getElementById("divProcessing").innerHTML = "";
    window.open(Url, "_self");
}

//function ShowClientUpdateUrlFromviewform(RecordId) {
//    document.getElementById("divProcessing").innerHTML = "Hệ thống đang xử lý";
//    Url = Portal.SODC.IDIS.DetailsPrecintIllegal.GetShowUpdateForm(RecordId).value;
//    if (Url.indexOf("ERROR") != -1) {
//        document.getElementById("divProcessing").innerHTML = "";
//        alert(Url);
//        return;
//    }
//    document.getElementById("divProcessing").innerHTML = "";
//    window.open(Url, "_self");
//}
function ClientStatus() {
    alert("Chuyên mục này đang xây dựng!");
    return;
}

function ClientExportData() {
    var ltype = $("#_locationLevelTypeSelect").val();
    if (ltype == "0") {
        alert("Chưa chọn cấp địa phương!");
        document.getElementById("divProcessing").innerHTML = "";
        return;
    }
    var LocationId = $("#_locationsel").val();
    FromDate = document.getElementById("drpDayplistdatefrom").options[document.getElementById("drpDayplistdatefrom").selectedIndex].value + '/' + document.getElementById("drpMonthplistdatefrom").options[document.getElementById("drpMonthplistdatefrom").selectedIndex].value + '/' + document.getElementById("drpYearplistdatefrom").options[document.getElementById("drpYearplistdatefrom").selectedIndex].value;
    ToDate = document.getElementById("drpDayplistdateto").options[document.getElementById("drpDayplistdateto").selectedIndex].value + '/' + document.getElementById("drpMonthplistdateto").options[document.getElementById("drpMonthplistdateto").selectedIndex].value + '/' + document.getElementById("drpYearplistdateto").options[document.getElementById("drpYearplistdateto").selectedIndex].value;
    
    Ret = Portal.SODC.IDIS.ListPrecintIllegal.ServerExportData(ltype,LocationId, FromDate, ToDate).value;
    if (Ret.indexOf("ERROR") != -1) {
        alert(Ret.replace("ERROR:", ""));
        return;
    } else {
        window.open(Ret, "_blank");
        //alert(Ret);
    }
}

function checkformatnumbervie(a, textboxid, labelid) {
    var number = $("#" + textboxid + "").val();
    var isnumber = /^[0-9]+/;
    if (!isnumber.test(number)) {
        alert("Dữ liệu ở ô cần nhập phải là dữ liệu số!");
        document.getElementById("" + textboxid + "").select();
        return;
    }
    value = Portal.SODC.IDIS.Dictionarys.ReformatNumberVie(number).value;
   // alert(value);
    //a.title = value;
    document.getElementById("" + labelid + "").innerHTML = value;
}